﻿import com.dmotiko.zonaoutlet.*
import com.dmotiko.general.*
import mx.utils.Delegate;

class ZOOutletSpecial
extends BaseClip {
	private var mcPhoto:PhotoClip;
	private var mcIcon:PhotoClip;
	private var mcBorder:MovieClip;
	private var mcStroke:MovieClip;
			
	private function refreshData() {
		mcIcon.setData( data.logoSrc );
		mcPhoto.setData( data.specialSrc );
	}
	
	public function childLoaded( evnt ):Void {
		if (!data) return;
		switch( evnt.target ) {
			
			case mcPhoto:
			mcPhoto.setData( data.specialSrc );
			break;
			
			case mcIcon:
			mcIcon.setData( data.logoSrc );
			mcIcon.addEventListener( BaseClipEvent.READY, Delegate.create( this, center_logo) );
			break;
			
		}
	}
	
	private function center_logo( evnt ):Void {
		var clip:MovieClip = evnt.target;
		clip._x = ( this._width - clip._width ) / 2;
		clip._y = ( (mcStroke._y - clip._y) - (clip._height - clip._y) ) / 2;
	}
	
	public function onRollOver():Void {
		mcBorder.gotoAndPlay("over");
	}
	public function onRollOut():Void {
		mcBorder.gotoAndPlay("out");
	}
		
	public function onRelease():Void {
		this.dispatchEvent( { type: BaseClipEvent.CHANGED, target: this, data: data } );
	}
	
}